package 力扣._3248_矩阵中的蛇;

import java.util.List;

class Solution {
    public int finalPositionOfSnake(int n, List<String> commands) {
        int i = 0, j = 0;
        for (String command : commands) {
            switch (command) {
                case "UP":
                    i--;
                    break;
                case "DOWN":
                    i++;
                    break;
                case "LEFT":
                    j--;
                    break;
                case "RIGHT":
                    j++;
                    break;
            }
        }
        return i * n + j;
    }
}